package org.snaker.engine.parser.logicflow.node;


import org.snaker.engine.model.DecisionModel;
import org.snaker.engine.model.NodeModel;
import org.snaker.engine.parser.logicflow.LogicFlowJSONAbstractNodeParser;
import org.snaker.engine.parser.logicflow.model.LogicFlowData;

/**
 *
 * 决策节点解析类
 * @author mldong
 * @date 2023/4/26
 */
public class DecisionParser extends LogicFlowJSONAbstractNodeParser {


    /**
     * 解析decision节点特有属性
     * @param node 逻辑判断节点
     */
    @Override
    protected void parseNode(NodeModel model, LogicFlowData.Node node) {
        DecisionModel decisionModel = (DecisionModel) nodeModel;
        LogicFlowData.Properties properties = node.getProperties();
        decisionModel.setExpr(properties.get(ATTR_EXPR));
        decisionModel.setHandleClass(properties.get(ATTR_HANDLECLASS));
    }

    @Override
    public NodeModel newModel() {
        return new DecisionModel();
    }
}
